﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BLL.Entities.Company;

namespace HTAProDataImporterTest
{
    [TestClass]
    public class TestCourts : BaseImporterTest
    {
        CourtLocation court;

        public TestCourts()
        {
            court = data_importer.store.Courts["9"] as CourtLocation;
        }

        
        [TestMethod]
        public void CheckCourtFields()
        {
            
            Assert.IsNotNull(court, "Court is null");
            Assert.AreEqual(court.Name, "Richmond Hill");
            Assert.AreEqual(court.Address.AddressLine, "50 High Tech Rd., 1st Floor");
            Assert.AreEqual(court.Address.City, "Richmond Hill");
            Assert.AreEqual(court.Address.Province, "ON");
            Assert.AreEqual(court.Address.PostalCode, "L4B 4N7");

            Assert.AreEqual(court.Contact.PhoneWork, "(905) 762-2105");
            Assert.AreEqual(court.Contact.Fax, "(905) 762-2106");

            Assert.AreEqual(court.AppealCourtAddress.AddressLine, "50 Eagle Street West");
            Assert.AreEqual(court.AppealCourtAddress.City, "Newmarket");
            Assert.AreEqual(court.AppealCourtAddress.Province, "ON");
            Assert.AreEqual(court.AppealCourtAddress.PostalCode, "L4B 4N7");

            Assert.AreEqual(court.ICON, 4961);
            Assert.AreEqual(court.Region, "York");


         
        }

        [TestMethod]
        public void CheckProsecutorsCollection()
        {

            Assert.AreEqual(court.Prosecutors.Count, 2);

            CourtProsecutor pr_1 = null, pr_3 = null;

            foreach (CourtProsecutor pr in court.Prosecutors)
                switch(pr.CaseType.Value)
                {
                    case "Part 1 (Municipal) Prosecutor":
                        pr_1 = pr;
                        break;
                    case "Part 3 (Provincial) Prosecutor":
                        pr_3 = pr;
                        break;
                    default:
                        Assert.Fail("Unknown prosecutor type");
                        break;
                }

            Assert.AreEqual(pr_1.Address.AddressLine, "50 High Tech Rd.");
            Assert.AreEqual(pr_1.Address.City, "Richmond Hill");
            Assert.AreEqual(pr_1.Address.Province, "ON");
            Assert.AreEqual(pr_1.Address.PostalCode, "L4B 4N7");

            Assert.AreEqual(pr_1.Contact.PhoneWork, "(905) 762-2108 ext: 3316/17/18");
            Assert.AreEqual(pr_1.Contact.Fax, "(905) 762-2107");



            Assert.AreEqual(pr_3.Address.AddressLine, "465 Davis Dr.");
            Assert.AreEqual(pr_3.Address.City, "Newmarket");
            Assert.AreEqual(pr_3.Address.Province, "ON");
            Assert.AreEqual(pr_3.Contact.Fax, "(905) 895-7354");
                
            
        }
    }
}
